package com.yueman.ptoolopenticket.ticket.utils.lixin;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;


public class LxhwCommonConfig {
	public String configpath="LxhwCommonConfig.properties";
	private static LxhwCommonConfig instance;
	private static Properties p=null;
	public String getConfigpath() {
		return configpath;
	}

	public void setConfigpath(String configpath) {
		this.configpath = configpath;
	}

	public static LxhwCommonConfig getInstance(){
		if(instance == null) {
			instance = new LxhwCommonConfig();
		}
		return instance;
	}

	public String getProperties(String proId){
		if(p==null){
			InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(configpath);
			p = new Properties();
			try {
				p.load(inputStream);
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
		return p.getProperty(proId);
	}

	public String getProperties(String proId, String defaultValue){
		if(p==null){
			InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(configpath);
			p = new Properties();
			try {
				p.load(inputStream);
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
		String value = p.getProperty(proId);
		if(value==null){
			value=defaultValue;
		}
		return value;
	}

	public static void main(String[] args) {

	}
}
